import 'package:flutter/material.dart';
import 'package:flutterapp/util/colorUtil.dart';
import 'package:flutterapp/component/container.dart';
import 'package:flutterapp/component/form.dart';
import 'package:flutterapp/component/image.dart';
import 'package:flutterapp/component/scroll.dart';
import 'package:flutterapp/component/webview.dart';

class ComponentPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("基础组件"),
      ),
      body: ComponentContent(),
    );
  }
}

class ComponentContent extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => ComponentContentState();
}

class ComponentContentState extends State<ComponentContent> {
  @override
  Widget build(BuildContext context) {
    return Container(
      width: double.infinity,
      height: double.infinity,
      margin: EdgeInsets.fromLTRB(15, 0, 15, 0),
      child: Column(
        children: <Widget>[
          MaterialButton(
            color: ColorUtil.hexStringColor("#00BFFF"),
            textColor: Colors.white,
            minWidth: double.infinity,
            child: Text("Container 容器"),
            onPressed: () {
              Navigator.of(context).push(
                  MaterialPageRoute(builder: (context) => ContainerPage()));
            },
          ),
          MaterialButton(
            color: ColorUtil.hexStringColor("#f391a9"),
            textColor: Colors.white,
            minWidth: double.infinity,
            child: Text("Form 常用组件"),
            onPressed: () {
              Navigator.of(context)
                  .push(MaterialPageRoute(builder: (context) => FormPage()));
            },
          ),
          MaterialButton(
            color: ColorUtil.hexStringColor("#2a5caa"),
            textColor: Colors.white,
            minWidth: double.infinity,
            child: Text("Image 组件"),
            onPressed: () {
              Navigator.of(context)
                  .push(MaterialPageRoute(builder: (context) => ImagePage()));
            },
          ),
          MaterialButton(
            color: ColorUtil.hexStringColor("#b7ba6b"),
            textColor: Colors.white,
            minWidth: double.infinity,
            child: Text("SingleChildScrollView 组件"),
            onPressed: () {
              Navigator.of(context)
                  .push(MaterialPageRoute(builder: (context) => ScrollPage()));
            },
          ),
          MaterialButton(
            color: ColorUtil.hexStringColor("#f8aba6"),
            textColor: Colors.white,
            minWidth: double.infinity,
            child: Text("WebView 组件"),
            onPressed: () {
              Navigator.of(context)
                  .push(MaterialPageRoute(builder: (context) => WebViewPage()));
            },
          ),
        ],
      ),
    );
  }
}
